Skip to content

Surface HTTP and audio system error details#134

Open
orenidan wants to merge 3 commits intodimitris-c:mainfrom
orenidan:oren/surface-errors
Open

Surface HTTP and audio system error details#134
orenidan wants to merge 3 commits intodimitris-c:mainfrom
orenidan:oren/surface-errors

Conversation

@orenidan
Copy link

@orenidan orenidan commented Mar 22, 2026

Summary

  • change NetworkError.serverError to carry HTTPResponseDetails instead of only a status code
  • preserve HTTP status, URL, content type, headers, and an optional short body snippet for non-success responses
  • preserve typed NetworkError values through AudioPlayer instead of flattening them into generic failures
  • carry underlying details through audio system failures and include domain/code in descriptions
  • add regression coverage for the surfaced network and audio system error paths

Why

Today the library collapses several useful failure modes into generic errors before they reach consumers.

For HTTP failures, RemoteAudioSource sees the full HTTPURLResponse, but only surfaces a bare serverError value. That loses context that is often required to debug real-world stream failures, such as:

  • whether the response was HTML instead of audio
  • which URL ultimately failed
  • whether the response included redirect, CDN, or proxy headers
  • whether the server returned any short textual denial message

That loss of detail makes it hard for apps using the library to distinguish cases like:

  • a dead stream URL
  • a stream endpoint returning 403
  • a CDN/WAF denial page
  • a bad redirect target
  • a non-audio response from an otherwise reachable host

This came up in practice while debugging a station that:

  • answered small range probes successfully
  • but rejected real playback requests with 403
  • and only exposed that clearly once the HTTP response details were preserved

There is a similar issue on the playback side: typed NetworkError values were being wrapped again as generic .failure(error) values before reaching consumers. This PR keeps those typed errors intact so the additional diagnostics are not lost on the way out.

For audio system failures, the library already had typed cases such as engineFailure and playerNotFound, but those cases did not always preserve any underlying error details. This PR keeps domain/code information where available so consumers can see more than a generic failure string.

Scope

This PR is focused on diagnostics and error surfacing. It does not change the library's existing HTTP failure classification behavior; it preserves more context for failures the library already treats as errors.

Testing

  • swift test --filter NetworkErrorTests

@orenidan orenidan force-pushed the oren/surface-errors branch from 243b5d4 to ab0300e Compare March 22, 2026 06:36
@orenidan orenidan closed this Mar 22, 2026
@orenidan orenidan reopened this Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant